<table width="100%">
<tr id="sale_view_<?php echo $id?>" class="layby_list_view">
<td colspan="8">
    <h4>Normal Sales Item(s)</h4>
	<table class="layby_list_view_table">
		<thead>
			<tr>
				<td>Item no.</td>
				<td>Item name</td>
				<td>Original price</td>
				<td>Sale price</td>
				<td>Discount</td>
			</tr>
		</thead>
		<tbody>
			<?php foreach($saleItem as $li){
				$sale_price=$li["Item"]["original_price"];
				$discount="0";
				if(!empty($li["SaleItem"]["discount_amount"])){
					if($li["SaleItem"]["discount_type"]=="Percentage"){
						$sale_price=$li["Item"]["original_price"]*(100-$li["SaleItem"]["discount_amount"])/100;
						$discount=$li["SaleItem"]["discount_amount"]."%";
					}else{
						$sale_price=$li["Item"]["original_price"]-$li["SaleItem"]["discount_amount"];
						$discount=$this->Number->currency($li["SaleItem"]["discount_amount"],"USD");
					}
				}
			?>
			<tr>
				<td><?php echo $li["SaleItem"]["item_id"]?></td>
				<td><?php echo $li["Item"]["name"]?></td>
				<td><?php echo $this->Number->currency($li["Item"]["original_price"],"USD")?></td>
				<td><?php echo $this->Number->currency($sale_price,"USD")?></td>
				<td><?php echo $discount?></td>
			</tr>
			<?php }?>
		</tbody>
	</table>
	<?php if(!empty($laybyItem)){?>
	<h4>Layby Sales Item(s)</h4>
	<table class="layby_list_view_table layby_list_view_table_2">
		<thead>
			<tr>
				<td>Item no.</td>
				<td>Item name</td>
				<td>Original price</td>
				<td>Sale price</td>
				<td>Initial amount</td>
				<td>&nbsp;</td>
			</tr>
		</thead>
		<tbody>
			<?php foreach($laybyItem as $li){
				$sale_price=$li["Item"]["original_price"];
				$discount="0";
				if(!empty($li["Item"]["discount_amount"])){
					if($li["Item"]["discount_type"]=="Percentage"){
						$sale_price=$li["Item"]["original_price"]*(100-$li["Item"]["discount_amount"])/100;
						$discount=$li["Item"]["discount_amount"]."%";
					}else{
						$sale_price=$li["Item"]["original_price"]-$li["Item"]["discount_amount"];
						$discount=$this->Number->currency($li["Item"]["discount_amount"],"USD");
					}
				}
			?>
			<tr>
				<td><?php echo $li["SaleItem"]["item_id"]?></td>
				<td><?php echo $li["Item"]["name"]?></td>
				<td><?php echo $this->Number->currency($li["Item"]["original_price"],"USD")?></td>
				<td><?php echo $this->Number->currency($sale_price,"USD")?></td>
				<td><?php echo $li["SaleItem"]["layby_amount"]?></td>
				<td><a class="btn layby_view" href="javascript:;" data-id="<?php echo $li["SaleItem"]["layby_id"]?>">View layby</a></td>
			</tr>
			<?php }?>
		</tbody>
	</table>
	<?php }?>
</td>
</tr>
</table>